<?php
/**
 * Main Graphical user interface elements
 * 
 * @author Mykolas Jarašiūnas
 */
$page_title = htmlspecialchars($page_title);
//FIXME: normal GUI path evaluation
if (strpos($_SERVER['REQUEST_URI'], '/GUI/') !== false) {
    $prefix = '';
} else {
    $prefix = 'GUI/Design/';
    $js_prefix = 'GUI/Functions/';
}
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";

//FIXME: normal GUI path evaluation
if (strpos($_SERVER['REQUEST_URI'], '/GUI/') !== false) {
    $prefix = '';
} else {
    $prefix = 'GUI/Design/';
    $js_prefix = 'GUI/Functions/';
    $js_plugins = 'Plugins/';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="lt" lang="lt">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
        <meta http-equiv="Pragma" content="no-cache" />
        <meta http-equiv="Expires" content="-1" />
        <link rel="stylesheet" href="<?= $prefix; ?>main.css" type="text/css"/>
        <link rel="stylesheet" href="<?= $prefix; ?>printer.css" type="text/css" media="print"/>
        <link rel="stylesheet" href="Plugins/SlickGrid/slick.grid.css" type="text/css" media="screen" charset="utf-8" />
        <link rel="stylesheet" href="Plugins/SlickGrid/css/smoothness/jquery-ui-1.8.16.custom.css" type="text/css" media="screen" charset="utf-8" />

        <script type="text/javascript" src="Plugins/jquery-1.7.min.js"></script>
        <script type="text/javascript" src="Plugins/jquery.cookie.js"></script>

        <script src="<?= $js_prefix; ?>table.js" type="text/javascript"></script>
        <script src="<?=$js_prefix;?>jquery.numeric.js" type="text/javascript"></script>
        <script src="<?= $js_prefix; ?>diagrams.js" type="text/javascript"></script>
        <script src="<?= $js_prefix; ?>ElementsShow.js" type="text/javascript"></script>
        <script src="<?= $js_prefix; ?>show_full_size.js" type="text/javascript"></script>
        <script src="<?= $js_prefix; ?>tabber.tab_control.js" type="text/javascript"></script>
        <script src="<?=$js_prefix;?>help.js" type="text/javascript"></script>

        <? if (strpos($_SERVER['REQUEST_URI'], 'database') !== false ||  strpos($_SERVER['REQUEST_URI'], 'minimal') !== false) { ?>
            <script type="text/javascript" src="Plugins/SlickGrid/lib/firebugx.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/lib/jquery-ui-1.8.16.custom.min.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/lib/jquery.event.drag-2.0.min.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/slick.core.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/plugins/slick.cellrangedecorator.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/plugins/slick.cellrangeselector.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/plugins/slick.cellselectionmodel.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/slick.editors.js"></script>
            <script type="text/javascript" src="Plugins/SlickGrid/slick.grid.js"></script>
        <? } ?>
	    
	<script type="text/javascript" src="Plugins/SlickGrid/lib/jquery-ui-1.8.16.custom.min.js"></script>

        <? if (strpos($_SERVER['REQUEST_URI'], 'foresee') !== false) { ?>
            <script type="text/javascript" src="Plugins/Tabber/tabber.js"></script>
            <script type="text/javascript" src="Plugins/Tabber/tabber.cookie.js"></script>
        <? } ?>       
        <title><?= $page_title; ?></title>
    </head>
    <body>
        <div class="box_left">
            <div class="box_right">
                <div class="logo_container">
                    <div class="logo">
                        <a href="?"><img alt="PAA" src="GUI/Design/Images/logo.png" width="200" height="100"/></a>
                    </div>
                    <div class="logo_info_bar">
                        <? if (isset($user)) { ?>
                            <span id="logged_in_as">Prisijungęs: <?php echo $user['username']; ?> <a id="logout" href="index.php?logout">Atsijungti</a></span>
                        <? } ?>
                        <a id="show_full" onclick="toggleFullSize()" href="#">Rodyti visu dydžiu</a> 
                        <script type="text/javascript"> if (window.opera) { document.getElementById("show_full").style.paddingRight = '30px'} </script>
                    </div>
                    <div class="tabs">
                    <?php
                    if (!$tabs && $tabs_array) {
                        $tabs = "";
                        foreach ($tabs_array as $tab_link => $info) {
                            list($tabFile, $name) = explode('|', $info, 2);
                            $tabs .= tabHeader($name, "?$tab_link", $requested_tab == $tab_link);
                        }
                    }
                    if ($tabs) {
                        echo $tabs;
                    }
                    ?>
                    </div>
                </div>

                <div class="sidebar">
                    <?
                    print $sidebar_content;
                    //if ($help != "") {
                        print form_help_widget($help);
                    //}
                    ?>
                </div>
                <div class="main_content">
                    <?php
                    print messages("warning");
                    print messages("error");
                    print messages("success");
                    print $main_content;
                    ?>

                </div>
                <div class="floater"></div>
            </div>
        </div>
        <div id="footer">Paramos administravimo asistentas | Sprendimas: <a href="mailto:gramasoft@googlegroups.com">GRAMAsoft</a> 2011.<br/><small><?= $footer; ?></small></div>
    </body>
</html>        